package classics.simulate;

/**
 * @Description
 * @Author asrieal
 * @Date 2021/9/14
 */
public class Ex151 {
    public String reverseWords(String s) {
        StringBuilder res = new StringBuilder();
        String[] sp = s.split(" ");
        for (int i = s.length()-1; i >0 ; i--) {
            if(!sp[i].equals(" ")){
                res.append(sp[i]);
                res.append(" ");
            }
        }
        res.delete(res.length(),res.length());
        return res.toString();
    }
}
